package com.zt.java.proxy;

public class InterceptorChain {

    private AbstractInterceptorHander first;

    private AbstractInterceptorHander last;

    public Object intercept(Invocation invocation){
        if(first!=null){
            return first.intercept(invocation);
        }
        return null;
    }

    public void addInterceptor(AbstractInterceptorHander last){
        if(this.first == null){
            this.first = last;
            this.last = last;
        }else{
            this.last  = last;
        }
    }

    public AbstractInterceptorHander getFirst() {
        return first;
    }

    public void setFirst(AbstractInterceptorHander first) {
        this.first = first;
    }

    public AbstractInterceptorHander getLast() {
        return last;
    }

    public void setLast(AbstractInterceptorHander last) {
        this.last = last;
    }

}
